from urllib import request,parse

my_url = "http://www.renren.com/541197383/profile"

headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36",
    "Cookie":"anonymid=juagdpiney0yg3; _r01_=1; jebe_key=af15eb55-de2a-49f2-8861-fe6e628d49ed%7C67510b08b897c5e3b50e55d3a235a53c%7C1554854833372%7C1%7C1554854833452; ln_uact=gaohj5@163.com; ln_hurl=http://head.xiaonei.com/photos/0/0/men_main.gif; _de=28A69782AB906D4A677B8FA35C706602; depovince=HUB; jebecookies=ca9c7735-cd1e-42c5-82bf-daf00967df0e|||||; JSESSIONID=abc-s1FjttthX5y5zF1Uw; ick_login=007517d4-bc2a-4f93-8e2c-536f11ba0b34; p=3ef8f5c7cc3c4800f8e1d1932e1b379f3; first_login_flag=1; t=895a2a686c33d36f52a7ea0c9e8403e13; societyguester=895a2a686c33d36f52a7ea0c9e8403e13; id=541197383; xnsid=4a82308b; ver=7.0; loginfrom=null; wp_fold=0; jebe_key=af15eb55-de2a-49f2-8861-fe6e628d49ed%7C67510b08b897c5e3b50e55d3a235a53c%7C1562118139179%7C1%7C1562118139306"
}

req = request.Request(my_url,headers=headers)
resp = request.urlopen(req)
with open('renren.html','w',encoding='utf-8') as fp:
    #resp.read() 读出来的字节数据类型
    # bytes -> decode -> str
    # str ->enoode -> bytes
    fp.write(resp.read().decode('utf-8'))